package com.guigu.mongo;



import com.adesign.com.guigu.Model.User;
import com.adesign.com.guigu.repository.UserRepository;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Date;
import java.util.List;

@SpringBootTest(classes = com.adesign.mongoApplication.class)
public class test {


    @Autowired
    private UserRepository userRepository;

    @Test
    public void test()
    {
        User user = new User();
        user.setName("lucy");
        user.setAge(18);
        user.setCreateDate(new Date());
        userRepository.save(user);



    }

    // 查询所有
    @Test
    public void checkall()
    {
        List<User> all = userRepository.findAll();
        for (User user : all) {
            System.out.println(user.getName());
        }
    }
}
